package com.mszl.blog.service.impl;

import com.mszl.blog.dao.ArticleTagDao;
import com.mszl.blog.entity.ArticleTag;
import com.mszl.blog.dao.ArticleTagDao;
import com.mszl.blog.service.ArticleTagService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import javax.annotation.Resource;

/**
 * (ArticleTag)表服务实现类
 *
 * @author makejava
 * @since 2025-08-09 12:03:21
 */
@Service("articleTagService")
public class ArticleTagServiceImpl implements ArticleTagService {
    @Resource
    private ArticleTagDao articleTagDao;

    @Override
    public ArticleTag queryById(Long id) {
        return this.articleTagDao.queryById(id);
    }

    @Override
    public Page<ArticleTag> queryByPage(ArticleTag articleTag, PageRequest pageRequest) {
        long total = this.articleTagDao.count(articleTag);
        return new PageImpl<>(this.articleTagDao.queryAllByLimit(articleTag, pageRequest), pageRequest, total);
    }

    @Override
    public ArticleTag insert(ArticleTag articleTag) {
        this.articleTagDao.insert(articleTag);
        return articleTag;
    }

    @Override
    public ArticleTag update(ArticleTag articleTag) {
        this.articleTagDao.update(articleTag);
        return this.queryById(articleTag.getId());
    }

    @Override
    public boolean deleteById(Long id) {
        return this.articleTagDao.deleteById(id) > 0;
    }
}
